using Holoville.HOTween;
using Holoville.HOTween.Core;
using UnityEngine;

public class WindowLostMission : MonoBehaviour
{
	[SerializeField]
	private UIWidget widget;

	[SerializeField]
	private UIWidget top;

	[SerializeField]
	private UIWidget bot;

	private Vector3 startTopPos;

	private Vector3 startBotPos;

	public void Awake()
	{
		startTopPos = top.transform.localPosition;
		startBotPos = bot.transform.localPosition;
		widget.alpha = 0f;
		top.alpha = 0f;
		top.transform.localPosition = startTopPos + Vector3.right * 200f;
		bot.transform.localPosition = startTopPos + Vector3.left * 200f;
		bot.alpha = 0f;
	}

	public void ShowWindow(bool val)
	{
		MyMiniTween[] componentsInChildren = GetComponentsInChildren<MyMiniTween>();
		foreach (MyMiniTween myMiniTween in componentsInChildren)
		{
			myMiniTween.Show(val);
		}
		HOTween.Kill(widget);
		HOTween.Kill(top.transform);
		HOTween.Kill(bot.transform);
		HOTween.To(widget, 0.2f, new TweenParms().Prop("alpha", val ? 1 : 0));
		HOTween.To(top, 0.2f, new TweenParms().Prop("alpha", val ? 1 : 0));
		HOTween.To(bot, 0.2f, new TweenParms().Prop("alpha", val ? 1 : 0));
		HOTween.To(top.transform, 0.3f, new TweenParms().Prop("localPosition", (!val) ? (startTopPos + Vector3.right * 200f) : startTopPos).OnComplete((TweenDelegate.TweenCallback)delegate
		{
			if (!val)
			{
				top.transform.localPosition = startTopPos + Vector3.right * 200f;
				top.alpha = 0f;
			}
			else
			{
				HOTween.To(top.transform, 30f, new TweenParms().Prop("localPosition", startTopPos + Vector3.right * 100f));
				Invoke("Hide", 3f);
			}
		}));
		HOTween.To(bot.transform, 0.3f, new TweenParms().Prop("localPosition", (!val) ? (startBotPos + Vector3.left * 200f) : startBotPos).OnComplete((TweenDelegate.TweenCallback)delegate
		{
			if (!val)
			{
				bot.transform.localPosition = startTopPos + Vector3.left * 200f;
				bot.alpha = 0f;
			}
			else
			{
				HOTween.To(bot.transform, 30f, new TweenParms().Prop("localPosition", startBotPos + Vector3.left * 100f));
			}
		}));
	}

	public void Hide()
	{
		ShowWindow(false);
	}
}
